<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Polling (computer science)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Polling_(computer_science)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Polling_computer_science rootpage-Polling_computer_science skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Polling (computer science)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">This article is about the computer science term. For the mathematical model, see <a href="Polling_system" title="Polling system">Polling system</a>. For other uses, see <a href="Polling_(disambiguation)" class="mw-redirect mw-disambig" title="Polling (disambiguation)">Polling (disambiguation)</a>.</div>
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */
.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style>
<p><b>Polling</b>, or <b>interrogation</b>, refers to actively sampling the status of an <a href="External_device" class="mw-redirect" title="External device">external device</a> by a <a href="Client_program" class="mw-redirect" title="Client program">client program</a> as a synchronous activity. Polling is most often used in terms of <a href="Input/output" title="Input/output">input/output</a> (<span class="nowrap">I/O</span>), and is also referred to as <b>polled <span class="nowrap">I/O</span></b> or <b>software-driven <span class="nowrap">I/O</span></b>. A good example of hardware implementation is a <a href="Watchdog_timer" title="Watchdog timer">watchdog timer</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Description">Description</h2></div>
<p>Polling is the process where the computer or controlling device waits for an <a href="External_device" class="mw-redirect" title="External device">external device</a> to check for its readiness or state, often with low-level hardware. For example, when a <a href="Printer_(computing)" title="Printer (computing)">printer</a> is connected via a parallel port, the computer waits until the printer has received the next character. These processes can be as minute as only reading <a href="Status_register" title="Status register">one bit</a>. This is sometimes used synonymously with '<a href="Busy_waiting" title="Busy waiting">busy-wait</a>' polling. In this situation, when an <span class="nowrap">I/O</span> operation is required, the computer does nothing other than check the status of the <span class="nowrap">I/O</span> device until it is ready, at which point the device is accessed. In other words, the computer waits until the device is ready. Polling also refers to the situation where a device is repeatedly checked for readiness, and if it is not, the computer returns to a different task. Although not as wasteful of <a href="CPU" class="mw-redirect" title="CPU">CPU</a> cycles as busy waiting, this is generally not as efficient as the alternative to polling, <a href="Interrupt" title="Interrupt">interrupt</a>-driven <span class="nowrap">I/O</span>.
</p><p>In a simple single-purpose system, even busy-wait is perfectly appropriate if no action is possible until the <span class="nowrap">I/O</span> access, but more often than not this was traditionally a consequence of simple hardware or non-<a href="Computer_multitasking" title="Computer multitasking">multitasking</a> <a href="Operating_systems" class="mw-redirect" title="Operating systems">operating systems</a>.
</p><p>Polling is often intimately involved with very <a href="Machine_code" title="Machine code">low-level hardware</a>. For example, polling a parallel printer port to check whether it is ready for another character involves examining as little as one <a href="Bit" title="Bit">bit</a> of a <a href="Byte" title="Byte">byte</a>. That bit represents, at the time of reading, whether a single wire in the printer cable is at low or high voltage. The <span class="nowrap">I/O</span> instruction that reads this byte directly transfers the voltage state of eight real world wires to the eight circuits (<a href="Flip_flop_(electronics)" class="mw-redirect" title="Flip flop (electronics)">flip flops</a>) that make up one byte of a CPU register.
</p><p>Polling has the disadvantage that if there are too many devices to check, the time required to poll them can exceed the time available to service the I/O device.
</p>
<div class="mw-heading mw-heading3"><h3 id="Algorithm">Algorithm</h3></div>
<p>Polling can be described in the following steps:
</p><p>Host actions:
</p>
<ol><li>The host repeatedly reads the <a href="Status_register" title="Status register">busy bit</a> of the controller until it becomes clear (with a value of 0).</li>
<li>When clear, the host writes the command into the command <a href="Hardware_register" title="Hardware register">register</a>. If the host is sending output, it sets the write bit and writes a byte into the data-out register. If the host is receiving input, it reads the controller-written data from the data-in register, and sets the read bit to 0 as the next command.</li>
<li>The host sets the command-ready bit to 1.</li></ol>
<p>Controller actions:
</p>
<ol><li>When the controller notices that the command-ready bit is set, it sets the busy bit to 1.</li>
<li>The controller reads the command register. If the write bit inside is set, it reads from the data-out register and performs the necessary <span class="nowrap">I/O</span> operations on the device. If the read bit is set, data from the device is loaded into the data-in register for the host to read.</li>
<li>Once the operations are over, the controller clears the command-ready bit, clears the error bit to show the operation was successful, and clears the busy bit.</li></ol>
<div class="mw-heading mw-heading2"><h2 id="Types">Types</h2></div>
<p>A <b>polling cycle</b> is the time in which each element is monitored once. The optimal polling cycle will vary according to several factors, including the desired speed of response and the overhead (e.g., <a href="Scheduling_(computing)" title="Scheduling (computing)">processor time</a> and <a href="Bandwidth_(computing)" title="Bandwidth (computing)">bandwidth</a>) of the polling.
</p><p>In <b>roll call polling</b>, the polling device or process queries each element on a list in a fixed sequence. Because it waits for a response from each element, a timing mechanism is necessary to prevent lock-ups caused by non-responding elements. Roll call polling can be inefficient if the overhead for the polling messages is high, there are numerous elements to be polled in each polling cycle and only a few elements are active.
</p><p>In <i>hub polling</i>, also referred to as token polling, each element polls the next element in some fixed sequence. This continues until the first element is reached, at which time the polling cycle starts all over again.
</p><p>Polling can be employed in various computing contexts in order to control the execution or transmission sequence of the elements involved. For example, in multitasking operating systems, polling can be used to allocate processor time and other resources to the various competing processes.
</p><p>In networks, polling is used to determine which nodes want to access the network. It is also used by routing protocols to retrieve routing information, as is the case with EGP (<a href="Exterior_gateway_protocol" title="Exterior gateway protocol">exterior gateway protocol</a>).
</p><p>An alternative to polling is the use of <a href="Interrupt" title="Interrupt">interrupts</a>, which are <a href="Signal_(IPC)" title="Signal (IPC)">signals</a> generated by devices or processes to indicate that they need attention, want to communicate, etc. Although polling can be very simple, in many situations (e.g., multitasking operating systems) it is more efficient to use interrupts because it can reduce processor usage and/or bandwidth consumption.
</p>
<div class="mw-heading mw-heading2"><h2 id="Poll_message">Poll message</h2></div>
<p>A <b>poll message</b> is a control-acknowledgment message.
</p><p>In a multidrop line arrangement (a central <a href="Computer" title="Computer">computer</a> and different terminals in which the <a href="Terminal_(telecommunication)" title="Terminal (telecommunication)">terminals</a> share a single communication line to and from the computer), the system uses a <a href="Master/slave_(technology)" class="mw-redirect" title="Master/slave (technology)">master/slave</a> polling arrangement whereby the central computer sends message (called polling message) to a specific terminal on the outgoing line. All terminals listen to the outgoing line, but only the terminal that is polled replies by sending any information that it has ready for transmission on the incoming line.<sup id="cite_ref-mpb_1-0" class="reference"><a href="#cite_note-mpb-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</p><p>In <a href="Star_network" title="Star network">star networks</a>, which, in its simplest form, consists of one central <a href="Network_switch" title="Network switch">switch</a>, <a href="Ethernet_hub" title="Ethernet hub">hub</a>, or computer that acts as a conduit to transmit messages, polling is not required to avoid chaos on the lines, but it is often used to allow the master to acquire input in an orderly fashion. These poll messages differ from those of the multidrop lines case because there are no site addresses needed, and each terminal only receives those polls that are directed to it.<sup id="cite_ref-mpb_1-1" class="reference"><a href="#cite_note-mpb-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Abstraction_(computer_science)" title="Abstraction (computer science)">Abstraction (computer science)</a></li>
<li><a href="Asynchronous_I/O" title="Asynchronous I/O">Asynchronous I/O</a></li>
<li><a href="Bit_banging" title="Bit banging">Bit banging</a></li>
<li><a href="Infinite_loop" title="Infinite loop">Infinite loop</a></li>
<li><a href="Interrupt_request_(PC_architecture)" class="mw-redirect" title="Interrupt request (PC architecture)">Interrupt request (PC architecture)</a></li>
<li><a href="Integer_(computer_science)" title="Integer (computer science)">Integer (computer science)</a></li>
<li><a href="Kqueue" title="Kqueue">kqueue</a></li>
<li><a href="Pull_technology" title="Pull technology">Pull technology</a></li>
<li><a href="Select_(Unix)" title="Select (Unix)">select (Unix)</a></li>
<li><a href="Signal_(IPC)" title="Signal (IPC)">Signal (IPC)</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-mpb-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-mpb_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-mpb_1-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20140217174920/http://www.pulsewan.com/data101/multidrop_polling_basics.htm">"Multi-Drop Polling"</a>. RAD Data Communications/Pulse Supply. 2007. Archived from <a rel="nofollow" class="external text" href="http://www.pulsewan.com/data101/multidrop_polling_basics.htm">the original</a> on 2014-02-17<span class="reference-accessdate">. Retrieved <span class="nowrap">2014-07-13</span></span>.</cite></span>
</li>
</ol></div></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-04-13" href="https://en.wikipedia.org/wiki/?title=Polling_(computer_science)&oldid=1285358519">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>